/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.taobao.ibatiside.model.mapperv2.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import org.taobao.ibatiside.model.mapperv2.Discriminator;
import org.taobao.ibatiside.model.mapperv2.Mapperv2Package;
import org.taobao.ibatiside.model.mapperv2.Result;
import org.taobao.ibatiside.model.mapperv2.ResultMap;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Result Map</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.taobao.ibatiside.model.mapperv2.impl.ResultMapImpl#getResult <em>Result</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv2.impl.ResultMapImpl#getDiscriminator <em>Discriminator</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv2.impl.ResultMapImpl#getClass_ <em>Class</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv2.impl.ResultMapImpl#getExtends <em>Extends</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv2.impl.ResultMapImpl#getGroupBy <em>Group By</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv2.impl.ResultMapImpl#getId <em>Id</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv2.impl.ResultMapImpl#getXmlName <em>Xml Name</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ResultMapImpl extends EObjectImpl implements ResultMap {
	/**
	 * The cached value of the '{@link #getResult() <em>Result</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getResult()
	 * @generated
	 * @ordered
	 */
	protected EList<Result> result;

	/**
	 * The cached value of the '{@link #getDiscriminator() <em>Discriminator</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDiscriminator()
	 * @generated
	 * @ordered
	 */
	protected Discriminator discriminator;

	/**
	 * The default value of the '{@link #getClass_() <em>Class</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getClass_()
	 * @generated
	 * @ordered
	 */
	protected static final String CLASS_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getClass_() <em>Class</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getClass_()
	 * @generated
	 * @ordered
	 */
	protected String class_ = CLASS_EDEFAULT;

	/**
	 * The cached value of the '{@link #getExtends() <em>Extends</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getExtends()
	 * @generated
	 * @ordered
	 */
	protected ResultMap extends_;

	/**
	 * The default value of the '{@link #getGroupBy() <em>Group By</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getGroupBy()
	 * @generated
	 * @ordered
	 */
	protected static final String GROUP_BY_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getGroupBy() <em>Group By</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getGroupBy()
	 * @generated
	 * @ordered
	 */
	protected String groupBy = GROUP_BY_EDEFAULT;

	/**
	 * The default value of the '{@link #getId() <em>Id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getId()
	 * @generated
	 * @ordered
	 */
	protected static final String ID_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getId() <em>Id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getId()
	 * @generated
	 * @ordered
	 */
	protected String id = ID_EDEFAULT;

	/**
	 * The default value of the '{@link #getXmlName() <em>Xml Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getXmlName()
	 * @generated
	 * @ordered
	 */
	protected static final String XML_NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getXmlName() <em>Xml Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getXmlName()
	 * @generated
	 * @ordered
	 */
	protected String xmlName = XML_NAME_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ResultMapImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return Mapperv2Package.Literals.RESULT_MAP;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Result> getResult() {
		if (result == null) {
			result = new EObjectContainmentEList<Result>(Result.class, this, Mapperv2Package.RESULT_MAP__RESULT);
		}
		return result;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Discriminator getDiscriminator() {
		return discriminator;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetDiscriminator(Discriminator newDiscriminator, NotificationChain msgs) {
		Discriminator oldDiscriminator = discriminator;
		discriminator = newDiscriminator;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Mapperv2Package.RESULT_MAP__DISCRIMINATOR, oldDiscriminator, newDiscriminator);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDiscriminator(Discriminator newDiscriminator) {
		if (newDiscriminator != discriminator) {
			NotificationChain msgs = null;
			if (discriminator != null)
				msgs = ((InternalEObject)discriminator).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - Mapperv2Package.RESULT_MAP__DISCRIMINATOR, null, msgs);
			if (newDiscriminator != null)
				msgs = ((InternalEObject)newDiscriminator).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - Mapperv2Package.RESULT_MAP__DISCRIMINATOR, null, msgs);
			msgs = basicSetDiscriminator(newDiscriminator, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv2Package.RESULT_MAP__DISCRIMINATOR, newDiscriminator, newDiscriminator));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getClass_() {
		return class_;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setClass(String newClass) {
		String oldClass = class_;
		class_ = newClass;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv2Package.RESULT_MAP__CLASS, oldClass, class_));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ResultMap getExtends() {
		return extends_;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setExtends(ResultMap newExtends) {
		ResultMap oldExtends = extends_;
		extends_ = newExtends;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv2Package.RESULT_MAP__EXTENDS, oldExtends, extends_));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getGroupBy() {
		return groupBy;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setGroupBy(String newGroupBy) {
		String oldGroupBy = groupBy;
		groupBy = newGroupBy;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv2Package.RESULT_MAP__GROUP_BY, oldGroupBy, groupBy));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getId() {
		return id;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setId(String newId) {
		String oldId = id;
		id = newId;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv2Package.RESULT_MAP__ID, oldId, id));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getXmlName() {
		return xmlName;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setXmlName(String newXmlName) {
		String oldXmlName = xmlName;
		xmlName = newXmlName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv2Package.RESULT_MAP__XML_NAME, oldXmlName, xmlName));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case Mapperv2Package.RESULT_MAP__RESULT:
				return ((InternalEList<?>)getResult()).basicRemove(otherEnd, msgs);
			case Mapperv2Package.RESULT_MAP__DISCRIMINATOR:
				return basicSetDiscriminator(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case Mapperv2Package.RESULT_MAP__RESULT:
				return getResult();
			case Mapperv2Package.RESULT_MAP__DISCRIMINATOR:
				return getDiscriminator();
			case Mapperv2Package.RESULT_MAP__CLASS:
				return getClass_();
			case Mapperv2Package.RESULT_MAP__EXTENDS:
				return getExtends();
			case Mapperv2Package.RESULT_MAP__GROUP_BY:
				return getGroupBy();
			case Mapperv2Package.RESULT_MAP__ID:
				return getId();
			case Mapperv2Package.RESULT_MAP__XML_NAME:
				return getXmlName();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case Mapperv2Package.RESULT_MAP__RESULT:
				getResult().clear();
				getResult().addAll((Collection<? extends Result>)newValue);
				return;
			case Mapperv2Package.RESULT_MAP__DISCRIMINATOR:
				setDiscriminator((Discriminator)newValue);
				return;
			case Mapperv2Package.RESULT_MAP__CLASS:
				setClass((String)newValue);
				return;
			case Mapperv2Package.RESULT_MAP__EXTENDS:
				setExtends((ResultMap)newValue);
				return;
			case Mapperv2Package.RESULT_MAP__GROUP_BY:
				setGroupBy((String)newValue);
				return;
			case Mapperv2Package.RESULT_MAP__ID:
				setId((String)newValue);
				return;
			case Mapperv2Package.RESULT_MAP__XML_NAME:
				setXmlName((String)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case Mapperv2Package.RESULT_MAP__RESULT:
				getResult().clear();
				return;
			case Mapperv2Package.RESULT_MAP__DISCRIMINATOR:
				setDiscriminator((Discriminator)null);
				return;
			case Mapperv2Package.RESULT_MAP__CLASS:
				setClass(CLASS_EDEFAULT);
				return;
			case Mapperv2Package.RESULT_MAP__EXTENDS:
				setExtends((ResultMap)null);
				return;
			case Mapperv2Package.RESULT_MAP__GROUP_BY:
				setGroupBy(GROUP_BY_EDEFAULT);
				return;
			case Mapperv2Package.RESULT_MAP__ID:
				setId(ID_EDEFAULT);
				return;
			case Mapperv2Package.RESULT_MAP__XML_NAME:
				setXmlName(XML_NAME_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case Mapperv2Package.RESULT_MAP__RESULT:
				return result != null && !result.isEmpty();
			case Mapperv2Package.RESULT_MAP__DISCRIMINATOR:
				return discriminator != null;
			case Mapperv2Package.RESULT_MAP__CLASS:
				return CLASS_EDEFAULT == null ? class_ != null : !CLASS_EDEFAULT.equals(class_);
			case Mapperv2Package.RESULT_MAP__EXTENDS:
				return extends_ != null;
			case Mapperv2Package.RESULT_MAP__GROUP_BY:
				return GROUP_BY_EDEFAULT == null ? groupBy != null : !GROUP_BY_EDEFAULT.equals(groupBy);
			case Mapperv2Package.RESULT_MAP__ID:
				return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id);
			case Mapperv2Package.RESULT_MAP__XML_NAME:
				return XML_NAME_EDEFAULT == null ? xmlName != null : !XML_NAME_EDEFAULT.equals(xmlName);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (class: ");
		result.append(class_);
		result.append(", groupBy: ");
		result.append(groupBy);
		result.append(", id: ");
		result.append(id);
		result.append(", xmlName: ");
		result.append(xmlName);
		result.append(')');
		return result.toString();
	}

} //ResultMapImpl
